home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / osi / isode / dosisode / DOSISODE80.ZIP / ISODE8.WRK / UNIX / LIB / DNS / NETBYNAM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-09  |  1.6 KB  |  49 lines

  1. #include <fiddle.h>
  2. /*
  3.  * Copyright (c) 1983 Regents of the University of California.
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms are permitted
  7.  * provided that: (1) source distributions retain this entire copyright
  8.  * notice and comment, and (2) distributions including binaries display
  9.  * the following acknowledgement:  ``This product includes software
  10.  * developed by the University of California, Berkeley and its contributors''
  11.  * in the documentation or other materials provided with the distribution
  12.  * and in all advertising materials mentioning features or use of this
  13.  * software. Neither the name of the University nor the names of its
  14.  * contributors may be used to endorse or promote products derived
  15.  * from this software without specific prior written permission.
  16.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  17.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  18.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19.  */
  20.  
  21. #if defined(LIBC_SCCS) && !defined(lint)
  22. static char sccsid[] = "@(#)getnetbyname.c    5.6 (Berkeley) 6/1/90";
  23. #endif /* LIBC_SCCS and not lint */
  24.  
  25. #include <netdb.h>
  26.  
  27. extern int _net_stayopen;
  28.  
  29. struct netent *
  30. getnetbyname(name)
  31.     register char *name;
  32. {
  33.     register struct netent *p;
  34.     register char **cp;
  35.  
  36.     setnetent(_net_stayopen);
  37.     while (p = getnetent()) {
  38.         if (strcmp(p->n_name, name) == 0)
  39.             break;
  40.         for (cp = p->n_aliases; *cp != 0; cp++)
  41.             if (strcmp(*cp, name) == 0)
  42.                 goto found;
  43.     }
  44. found:
  45.     if (!_net_stayopen)
  46.         endnetent();
  47.     return (p);
  48. }
  49.